/*
 * Copyright (C) 2008 Rob Cash
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * 	http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.robcash.commons.swing.wizard.model;

import org.robcash.commons.swing.wizard.WizardPanel;
import org.robcash.commons.swing.wizard.event.WizardModelChangeListener;

/**
 *
 * @author Rob
 */
public interface WizardModel extends Iterable<WizardPanel> {

    /**
     * Standard outcome name to advance to next wizard panel
     */
    public static final String NEXT = "next";

    /**
     * Add a wizard panel to the model
     * @param panel Panel to add
     */
    public void add(WizardPanel panel);

    /**
     * Add a wizard panel to the model
     * @param panel Panel to add
     * @param initial Indicates that this panel is the initial panel to display
     */
    public void add(WizardPanel panel, boolean initial);

    /**
     * Add a transition between two panels
     * @param startPanel Panel on which the transition starts
     * @param endPanel Panel on which the transition ends
     * @param transitionName Name of transition
     */
    public void add(WizardPanel startPanel, WizardPanel endPanel, String transitionName);

    /**
     * Get the current panel
     * @return Current wizrd panel
     */
    public WizardPanel getCurrentPanel();

    /**
     * Indicates if there was a panel displayed before the current one
     * @return <tt>true</tt> if there was a panel displayed before the current
     * one
     */
    public boolean hasPreviousPanel();
    
    /**
     * Go forward to the next panel, as identified by panelId
     * @param panelId Unique identifier of next wizard panel
     * @throws IllegalArgumentException Thrown if the specified panelId does not
     * correspond to a known panel or is not valid as the next panel
     */
    public void goToNextPanel(String panelId) throws IllegalArgumentException;

    /**
     * Go back to the previous panel
     */
    public void goToPreviousPanel();
    
    /**
     * Get a wizard panel by its unique identifier
     * @param id Wizard panel identifier
     * @return Wizard panel
     */
    public WizardPanel getPanel(String id);

    /**
     * Remove a wizard panel
     * @param panel Panel to remove
     * @return <tt>true</tt> if the panel was removed
     */
    public boolean remove(WizardPanel panel);

    /**
     * Reset the model to its original state
     */
    public void reset();
    
    /**
     * Add state change listener
     * @param listener State change listener
     */
    public void addWizardModelChangeListener(WizardModelChangeListener listener);

    /**
     * Add state change listener
     * @param listener State change listener
     */
    public void removeWizardModelChangeListener(WizardModelChangeListener listener);

}
